﻿using System;
using System.Reflection;
using System.Windows.Input;
using MDCAdminTool.Commands;
using Microsoft.ApplicationServer.Caching.AdminApi;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IntegrationTests
{

    [TestClass()]
    public class StopCacheClusterTest : BaseTest
    {

        [TestInitialize()]
        public void MyTestInitialize()
        {
            Cluster.Start();
            //WaitForStatus(Cluster, ServiceStatus.Up);
        }


        [TestMethod()]
        public void StopCacheClusterConstructorTest()
        {
            StopCacheCluster target = new StopCacheCluster();
        }

        [TestMethod()]
        [TimeoutAttribute(60000)]
        [DeploymentItem("MDCAdminTool.exe")]
        public void OnCanExecuteTest()
        {
            StopCacheCluster_Accessor target = new StopCacheCluster_Accessor();
            
            object sender = null;

            CanExecuteRoutedEventArgs e = makeCanExecuteRouteEventArgs(target, Cluster);

            Cluster.Stop();
            //WaitForStatus(Cluster, ServiceStatus.Down);

            target.OnCanExecute(sender, e);
            Assert.AreEqual(false, e.CanExecute);

            Cluster.Start();

            target.OnCanExecute(sender, e);
            Assert.AreEqual(true, e.CanExecute);

            //WaitForStatus(Cluster, ServiceStatus.Up);

            target.OnCanExecute(sender, e);
            Assert.AreEqual(true, e.CanExecute);
        }



        [TestMethod()]
        [TimeoutAttribute(60000)]
        [DeploymentItem("MDCAdminTool.exe")]
        public void OnExecutedTest()
        {
            StopCacheCluster_Accessor target = new StopCacheCluster_Accessor();
            
            object sender = null;

            ExecutedRoutedEventArgs e = makeExecutedRoutedEventArgs(target, Cluster);

            target.OnExecuted(sender, e);

            //WaitForStatus(Cluster, ServiceStatus.Down);
            Assert.AreEqual(ServiceStatus.Down, Cluster.Status);
        }

    }
}
